<template>
  <div class="dynamicContainer helpContainer">
    <!-- 头部 -->
    <van-nav-bar
      title="修改密码"
      left-arrow
      @click-left="onClickLeft"
      class="navheadrt"
    >
    </van-nav-bar>
    <div class="repwdcontent">
      <div class="item f fs">
        <img src="./imgs/pwd.png" alt="" class="fiveimg" />
        <input
          type="password"
          placeholder="请输入旧密码"
          v-model="query.oldPwd"
        />
      </div>
      <div class="item f fs">
        <img src="./imgs/edit.png" alt="" class="siximg" />
        <input
          type="password"
          placeholder="请输入新密码"
          v-model="query.newPwd"
        />
      </div>
      <div class="item f fs">
        <img src="./imgs/edit.png" alt="" class="siximg" />
        <input type="password" placeholder="请确认新密码" v-model="confiPwd" />
      </div>
    </div>
    <div class="confirmBtn f fc" @click="toSave()">确认修改</div>
  </div>
</template>
<script>
import { EditPassword } from "@/api/api";
export default {
  data() {
    return {
      query: {
        oldPwd: "",
        newPwd: "",
        uid: Number(localStorage.getItem("userId")),
      },
      confiPwd: "",
    };
  },
  mounted() {},
  methods: {
    // 返回按钮
    onClickLeft() {
      this.$router.go(-1);
    },
    toSave() {
      if (this.query.oldPwd.length == 0) {
        this.$message({
          message: "请输入旧密码！",
        });
      } else if (this.query.newPwd.length == 0) {
        this.$message({
          message: "请输入新密码！",
        });
      } else if (this.confiPwd.length == 0) {
        this.$message({
          message: "请输入确认密码！",
        });
      } else if (this.query.newPwd != this.confiPwd) {
        this.$message({
          message: "两次输入密码不一致！",
        });
      } else {
        this.Request(EditPassword(this.query)).then((res) => {
          if (res.StatusCode == "200") {
            this.$message({
              type: "success",
              message: res.Message,
              center: "true",
            });
            localStorage.clear();
            sessionStorage.clear();
            this.$router.push({ path: "/login" });
          } else {
            this.$message({
              type: "error",
              message: res.Message,
              center: "true",
            });
          }
        });
      }
    },
  },
};
</script>
<style lang="stylus" scoped>
@import './common/common';

$font-size-title = 36px;

.helpContainer {
  background: #fff;

  /deep/.van-cell__right-icon {
    font-size: 36px !important;
  }

  /deep/.van-cell {
    height: 90px;
    line-height: 90px;
    font-size: 28px;
  }

  /deep/.van-cell__right-icon {
    line-height: 90px !important;
  }

  .text {
    font-size: 30px !important;
    font-family: Microsoft YaHei;
    font-weight: 300;
    color: #000;
  }

  .pad20 {
    padding: 10px 0;
  }

  .qbg {
    padding: 0 10px;
    height: 40px;
    line-height: 30px;
    font-size: 20px;
    font-family: iekie;
    font-weight: normal;
    color: #FFFFFF;
    background: url('./imgs/qe.png') no-repeat;
    background-size: 100% 100%;
    margin-right: 30px;
  }
}

.navheadrt {
  /deep/ .van-nav-bar__title, /deep/.van-icon {
    color: #fff !important;
  }
}

.van-nav-bar {
  background: #699FFF;
  color: #fff !important;
  margin-bottom: 30px;
  height: 88px;
}

.van-nav-bar__title, .van-nav-bar__left, .van-nav-bar__right {
  color: #fff;
}

.van-icon-arrow-left {
  color: #fff;
  font-size: $font-size-title;
}

.repwdcontent {
  width: 100%;
  padding: 90px 40px 0;
  box-sizing: border-box;

  .item {
    width: 100%;
    border-bottom: 1px solid #D6D6D6;
    margin-bottom: 60px;
    padding-bottom: 15px;
    box-sizing: border-box;

    .fiveimg {
      width: 34px;
      height: 45px;
      margin-right: 60px;
    }

    .siximg {
      width: 35px;
      height: 34px;
      margin-right: 60px;
    }

    input {
      font-size: 28px;
    }
  }
}

.confirmBtn {
  width: 90%;
  height: 80px;
  background: #699fff;
  border: 2px solid #699fff;
  border-radius: 48px;
  font-size: 28px;
  font-family: FZLTXHK;
  font-weight: bold;
  color: #FFFFFF;
  position: fixed;
  bottom: 100px;
  left: 5%;
}
</style>